
/**
 * @param {navigateToUserAgreementsAction} action user agreements login action dictionary for the user login
 * @return navigate to the user greements login action dictionary page for the user login action
 */
type navigateToUserAgreementsAction = "service" | "privacye";
export const navigateToUserAgreements = (action: navigateToUserAgreementsAction) => {
  return navigateTo({ path: "/agreements", query: { action: action } });
};

/**
 * @param {userLoginAction} action user login action dictionary for the user login
 * @return navigate to the user login action dictionary page for the user login action
 */
type userLoginAction = "userNamePwdLoginContext" | "phoneCodeLoginContext";
export const navigateToUserLoginPage = (action: userLoginAction) => {
  return navigateTo({ path: "/user/login", query: { action: action } });
};

/**
 * 跳转到用户登录页面以执行特定操作
 *
 * @param action 需要执行的操作，类型为 navigateToUserHomeComponentAction
 * @returns 返回一个 Promise，表示导航操作的结果
 */
type navigateToUserHomeComponentAction = 'navigateToUserHome' | 'navigateToUserSeetting';
export const navigateToUserLoginPageForAction = (action: navigateToUserHomeComponentAction) => {
  return navigateTo({ path: "/home", query: { action: action } });
}
/**
 * @param {TopBarTitleMapper} action 用户首页面顶部标题映射
 */
interface TopBarTitleMapper extends UseDefineBackComponentShowItemType {
  title: navigateToUserHomeComponentAction,
  actionkey: string,
  define: string,
  icon: string,
  buttonBarTitleKey: string,
}

/**
 * 导航到用户主页显示的标题映射
 *
 * @param action 一个TopBarTitleMapper类型的函数，用于映射顶部栏标题
 * @returns 返回一个Promise，当导航完成后解析
 */
export const navigateToUserHomePageTitleMapper = [
  { title: 'navigateToUserHome', actionkey: "navigateToUserHomeViewTitle", define: "首页", icon: "home-o", buttonBarTitleKey: "navigateToUserHomeButtomBarView" },
  { title: 'navigateToUserSeetting', actionkey: "navigateToUserSettingViewTitle", define: "设置", icon: "setting-o", buttonBarTitleKey: "navigateToUserSeettingButtomBarView" }
] as Array<TopBarTitleMapper>;

/**
 * 获取用户主页顶部栏标题
 *
 * @param index 索引值，用于从映射表中找到对应的标题
 * @returns 用户主页顶部栏标题
 */
export const navigateToUserHomePageTopBarTitleShow = (index: number) => {
  const actionkey = navigateToUserHomePageTitleMapper[index];
  return localesGetValueForKey(actionkey?.actionkey, actionkey?.define) as string
}

/**
 * 根据给定的索引值获取对应的用户主页底部导航栏标题显示内容
 *
 * @param index 索引值，对应导航栏的标题
 * @returns 返回对应的标题字符串
 */
export const navigateToUserHomePageBottomBarTitleShow = (index: number) => {
  const actionkey = navigateToUserHomePageTitleMapper[index];
  return localesGetValueForKey(actionkey?.buttonBarTitleKey, actionkey?.define) as string
}
